/*
Author: Surpass-HC
Source: https://gitee.com/hxchuan000/clpc-1
Mail: surpass-hc@qq.com
*/
#if 0
#include <clptcCmdHeart.h>

// =============command hdemo begin=====================
void clptcHrtFunOvtSnd_hdemo(struct clptcHrtSnd_hdemo *idt)
{
    idt->v16 = ovtBigSys16(idt->v16);
    idt->v32 = ovtBigSys32(idt->v32);
}
void clptcHrtFunOvtResp_hdemo(struct clptcHrtResp_hdemo *odt)
{
    odt->v32 = ovtBigSysFloat(odt->v32);
}
#if CLPTC_CPL_SUB_ENABLE
void clptcHrtFunSubDo_hdemo(clptcParseStc *ptcptr, union clptcHrtUnion_hdemo *iodt)
{
    // input deal.
    logdebugc("shdemo:%d,%u,%s", iodt->idt.v16, iodt->idt.v32, iodt->idt.vbuf);
    // out deal.
    iodt->odt.v32 = 5.1f;
    snprintf(iodt->odt.vbuf, sizeof(iodt->odt.vbuf), "sub heart demo");
    // need set resp len.
    iodt->odt.comm.hlen = sizeof(struct clptcHrtResp_hdemo) - sizeof(struct clptcCmdHeartCommStc);
}
#endif
#if CLPTC_CPL_HOST_ENABLE
int clptcHrtFunHostPack_hdemo(clptcParseStc *ptcptr, int packAddr, int packCrypt, struct clptcHrtSnd_hdemo *packDt)
{
    struct clptcHrtSnd_hdemo *tmpdata = (struct clptcHrtSnd_hdemo *)clptcGetDataPtrV1(ptcptr);
    memcpy(tmpdata, packDt, sizeof(struct clptcHrtSnd_hdemo));

    tmpdata->comm.hcmd = clptcHrtEnum_hdemo;
    tmpdata->comm.hlen = sizeof(struct clptcHrtSnd_hdemo) - sizeof(struct clptcCmdHeartCommStc);
    // over turn user data.
    clptcHrtFunOvtSnd_hdemo(tmpdata);
    return clptcCmdFuncHostPack_heartBeat(ptcptr, packAddr, packCrypt, (clptcCmdStcSnd_heartBeat *)tmpdata);
}
int clptcHrtFunHostDo_hdemo(clptcParseStc *ptcptr, struct clptcHrtResp_hdemo *odt)
{
    logdebugc("hhdemo:%f,%s", odt->v32, odt->vbuf);
    return 1;
}
#endif
// =============command hdemo end======================

#if CLPTC_CPL_SUB_ENABLE
#define SWITH_SUB_HEART_ID_FUNC(hrtname)                                                                \
    case clptcHrtEnum_##hrtname:                                                                        \
    {                                                                                                   \
        clptcHrtFunOvtSnd_##hrtname((struct clptcHrtSnd_##hrtname *)clptcGetDataPtrV1(ptcptr));         \
        clptcHrtFunSubDo_##hrtname(ptcptr, (union clptcHrtUnion_##hrtname *)clptcGetDataPtrV1(ptcptr)); \
        clptcHrtFunOvtResp_##hrtname((struct clptcHrtResp_##hrtname *)clptcGetDataPtrV1(ptcptr));       \
        break;                                                                                          \
    }
int clptcHrtSubDealByID(clptcParseStc *ptcptr)
{
    clptcCmdStcSnd_heartBeat *tmpHrtCmd = (clptcCmdStcSnd_heartBeat *)clptcGetDataPtrV1(ptcptr);
    switch (tmpHrtCmd->comm.hcmd)
    {
        SWITH_SUB_HEART_ID_FUNC(hdemo);
    default:
    {
        logerrorc("heart cmd fail:%d", tmpHrtCmd->comm.hcmd);
        return -1;
    }
    }
    return 0;
}
#endif

#if CLPTC_CPL_HOST_ENABLE
#define SWITH_HOST_HEART_ID_FUNC(hrtname)                                                                       \
    case clptcHrtEnum_##hrtname:                                                                                \
    {                                                                                                           \
        clptcHrtFunOvtResp_##hrtname((struct clptcHrtResp_##hrtname *)clptcGetDataPtrV1(ptcptr));               \
        return clptcHrtFunHostDo_##hrtname(ptcptr, (struct clptcHrtResp_##hrtname *)clptcGetDataPtrV1(ptcptr)); \
    }
int clptcHrtHostDealByID(clptcParseStc *ptcptr)
{
    clptcCmdStcResp_heartBeat *tmpHrtResp = (clptcCmdStcResp_heartBeat *)clptcGetDataPtrV1(ptcptr);
    switch (tmpHrtResp->comm.hcmd)
    {
        SWITH_HOST_HEART_ID_FUNC(hdemo);
    default:
    {
        logerrorc("heart resp fail:%d", tmpHrtResp->comm.hcmd);
        break;
    }
    }
    return 0;
}
#endif
#endif